{extend name='common@layout/base' /}
{block name='breadcrumb'}
<div class="nch-breadcrumb-layout">
    <div class="nch-breadcrumb wrapper"><i class="icon-home"></i>
        <span><a href="/">首页</a></span><span class="arrow">></span>
        <span><a href="{:url('member/index/index')}">我的企业</a></span><span class="arrow">></span>
        <span>交易订单</span>
    </div>
</div>
{/block}
{block name='content'}
<div class="ncm-container">
    {include file='common@layout/member_left' /}
    <div class="right-layout">
        <link rel="stylesheet" type="text/css" href="/old/data/resource/js/jquery-ui/themes/ui-lightness/jquery.ui.css"  />

        <div class="wrap">
            <div class="tabmenu">
                {include file='common/submenu' /}
            </div>
            <form method="get" action="/" target="_self">
                <table class="ncm-search-table">
                    <input type="hidden" name="s" value="member/order/index" />
                    <input type="hidden" name= "recycle" value="{:input('recycle')}" />
                    <tr>
                        <td>&nbsp;</td>
                        <th>订单状态</th>
                        <td class="w100"><select name="state_type">
                                <option value="" <?php echo input('state_type')==''?'selected':''; ?>>所有订单</option>
                                <option value="state_new" <?php echo input('state_type')=='state_new'?'selected':''; ?>>待付款</option>
                                <option value="state_submit" <?php echo input('state_type')=='state_submit'?'selected':''; ?>>待确认</option>
                                <option value="state_pay" <?php echo input('state_type')=='state_pay'?'selected':''; ?>>待发货</option>
                                <option value="state_send" <?php echo input('state_type')=='state_send'?'selected':''; ?>>待收货</option>
                                <option value="state_success" <?php echo input('state_type')=='state_success'?'selected':''; ?>>已完成</option>
                                <option value="state_noeval" <?php echo input('state_type')=='state_noeval'?'selected':''; ?>>待评价</option>
                                <option value="state_cancel" <?php echo input('state_type')=='state_cancel'?'selected':''; ?>>已取消</option>
                            </select></td>
                        <th>下单时间</th>
                        <td class="w240"><input type="text" class="text w70" name="query_start_date" id="query_start_date" value="<?php echo $_GET['query_start_date']; ?>"/><label class="add-on"><i class="icon-calendar"></i></label>&nbsp;&#8211;&nbsp;<input type="text" class="text w70" name="query_end_date" id="query_end_date" value="<?php echo $_GET['query_end_date']; ?>"/><label class="add-on"><i class="icon-calendar"></i></label></td>
                        <th>订单号</th>
                        <td class="w160"><input type="text" class="text w150" name="order_sn" value="<?php echo $_GET['order_sn']; ?>"></td>
                        <td class="w70 tc"><label class="submit-border">
                                <input type="submit" class="submit" value="搜索"/>
                            </label></td>
                    </tr>
                </table>
            </form>
            <table class="ncm-default-table order">
                <thead>
                    <tr>
                        <th class="w10"></th>
                        <th colspan="2">商品</th>
                        <th class="w100">单价（元）</th>
                        <th class="w40">数量</th>
                        <th class="w100">售后</th>
                        <th class="w120">订单金额</th>
                        <th class="w100">交易状态</th>
                        <th class="w150">交易操作</th>
                    </tr>
                </thead>
                <?php if ($order_group_list) { ?>
                <?php foreach ($order_group_list as $order_pay_sn => $group_info) { ?>
                <?php $p = 0;?>
                <tbody order_id="" <?php if (!empty($group_info['pay_amount']) && $p == 0) {?> class="pay" <?php }?>>
                       <?php foreach($group_info['order_list'] as $order_id => $order_info) {?>
                       <?php if (empty($group_info['pay_amount'])) {?>
                       <tr>
                        <td colspan="19" class="sep-row"></td>
                    </tr>
                    <?php }?>
                    <?php if (!empty($group_info['pay_amount']) && $p == 0) {?>
                    <tr>
                        <td colspan="19" class="sep-row"></td>
                    </tr>
                    <tr>
                        <td colspan="19" class="pay-td">
                            <span class="ml15">
                                <?php if($order_info['payment_code'] == 'offline'){echo '线下支付金额：';}else{echo '在线支付金额：';} ?>
                                <em>￥<?php echo ncPriceFormat($group_info['pay_amount']);?></em>
                            </span> 
                            <a class="new_btn new_red_btn fr mr15" href="/?s=member/buy/pay&pay_sn=<?php echo $order_pay_sn; ?>">
                                <i class="icon-shield"></i>
                                订单支付
                            </a>
                        </td>
                    </tr>
                    <?php }?>
                    <?php $p++;?>
                    <tr>
                        <th colspan="19"> <span class="ml10">
                                订单号：<?php echo $order_info['order_sn']; ?>
                                <?php if ($order_info['order_from'] == 2){?>
                                <i class="icon-mobile-phone"></i>
                                <?php }?>
                            </span>
                            <span>下单时间：<?php echo date("Y-m-d H:i:s",$order_info['add_time']); ?></span>

                            <span><a href="<?php echo url('index/store/index',array('store_id'=>$order_info['store_id']));?>" title="<?php echo $order_info['name'];?>"><?php echo $order_info['store_name']; ?></a></span>

                            <span member_id="<?php echo $order_info['extend_store']['member_id'];?>">
                                <?php if(!empty($order_info['extend_store']['qq'])){?>
                                <a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=<?php echo $order_info['extend_store']['qq'];?>&site=qq&menu=yes" title="QQ: <?php echo $order_info['extend_store']['qq'];?>"><img alt="QQ: <?php echo $order_info['extend_store']['qq'];?>" border="0" src="http://wpa.qq.com/pa?p=2:<?php echo $order_info['extend_store']['qq'];?>:52" style=" vertical-align: middle;"/></a>
                                <?php }?>
                            </span> 
                            <!-- to do 分享
                            <a href="javascript:void(0)" class="share-goods" nc_type="sharegoods" data-param='{"gid":"<?php echo $order_info['goods_list'][0]['goods_id'];?>"}'><i class="icon-share"></i>分享</a>
                            -->

                            <?php if ($order_info['if_delete']) { ?>
                            <a href="javascript:void(0);" class="order-trash" onclick="ajax_get_confirm('您确定要删除吗?删除后该订单可以在回收站找回，或彻底删除', '/?s=member/order/change_state&state_type=order_delete&order_id=<?php echo $order_info['order_id']; ?>');"><i class="icon-trash"></i>删除</a>
                            <?php } ?>


                            <?php if ($order_info['if_restore']) { ?>
                            <a href="javascript:void(0);" class="order-trash" onclick="ajax_get_confirm('您确定要还原吗?', '/?s=member/order/change_state&state_type=order_restore&order_id=<?php echo $order_info['order_id']; ?>');"><i class="icon-refresh"></i>还原</a>
                            <?php } ?>
                        </th>
                    </tr>

                    <?php $i = 0;?>
                    <?php foreach ($order_info['goods_list'] as $k => $goods_info) {?>
                    <?php $i++;?>
                    <tr>
                        <td class="bdl"></td>
                        <td class="w70"><div class="ncm-goods-thumb"><a href="<?php echo $goods_info['goods_url'];?>" target="_blank"><img alt="<?php echo $goods_info['goods_name']; ?>" src="<?php echo $goods_info['image_60_url'];?>" onMouseOver="toolTip('<img src=<?php echo $goods_info['image_240_url'];?>>')" onMouseOut="toolTip()"/></a></div></td>
                        <td class="tl"><dl class="goods-name">
                                <dt><a href="<?php echo $goods_info['goods_url'];?>" target="_blank"><?php echo $goods_info['goods_name']; ?></a></dt>
                                <?php if (!empty($goods_info['goods_type_cn'])) { ?>
                                <dd><span class="sale-type"><?php echo $goods_info['goods_type_cn'];?></span></dd>
                                <?php } ?>
                            </dl></td>
                        <td><?php echo $goods_info['goods_price'];?></td>
                        <td><?php echo $goods_info['goods_num']; ?></td>
                        <td>

                            <?php if ($goods_info['refund'] == 1){?>
                            <p><a href="/?s=member/refund/add_refund&order_id=<?php echo $order_info['order_id']; ?>&goods_id=<?php echo $goods_info['rec_id']; ?>" target='_blank'>退款/退货</a></p>
                            <?php }?>


                            <?php if ($order_info['if_complain']){ ?>
                            <p><a href="/?s=member/complain/complain_new&order_id=<?php echo $order_info['order_id']; ?>&goods_id=<?php echo $goods_info['rec_id']; ?>" target='_blank'>交易投诉</a></p>
                            <?php } ?></td>

                        <?php if (($order_info['goods_count'] > 1 && $k ==0) || ($order_info['goods_count'] == 1)){?>
                        <td class="bdl" rowspan="<?php echo $order_info['goods_count'];?>"><p class=""><strong><?php echo $order_info['order_amount']; ?></strong></p>
                            <p class="goods-freight">
                                <?php if ($order_info['shipping_fee'] > 0){?>
                                (含运费<?php echo $order_info['shipping_fee'];?>)
                                <?php }else{?>
                                （免运费）
                                <?php }?>
                            </p>
                            <p title="支付方式：<?php echo $order_info['payment_name']; ?>"><?php echo $order_info['payment_name']; ?></p></td>
                        <td class="bdl" rowspan="<?php echo $order_info['goods_count'];?>"><p><?php echo $order_info['state_desc']; ?> <?php echo $order_info['evaluation_status'] ? '已评价' : '';?></p>


                            <p><a href="{:url('member/order/detail?order_id='.$order_info['order_id'])}" target="_blank">订单详情</a></p>


                            <?php if ($order_info['if_deliver']){ ?>
                            <p><a href='/?s=member/order/search_deliver&order_id=<?php echo $order_info['order_id']; ?>&order_sn=<?php echo $order_info['order_sn']; ?>' target="_blank">查看物流</a></p>
                            <?php } ?></td>
                        <td class="bdl bdr" rowspan="<?php echo $order_info['goods_count'];?>">


                            <?php if ($order_info['if_lock']) { ?>
                            <p>退款退货中</p>
                            <?php } ?>


                            <?php if ($order_info['if_cancel']) { ?>
                            <p><a href="javascript:void(0)" class="new_btn new_blue_border_btn" nc_type="dialog" dialog_width="480" dialog_title="取消订单" dialog_id="buyer_order_cancel_order" uri="/?s=member/order/change_state&state_type=order_cancel&order_id=<?php echo $order_info['order_id']; ?>"  id="order<?php echo $order_info['order_id']; ?>_action_cancel"><i class="icon-ban-circle"></i> 取消订单</a></p>
                            <?php } ?>


                            <?php if ($order_info['if_refund_cancel']){ ?>
                            <p><a href="/?s=member/refund/add_refund_all&order_id=<?php echo $order_info['order_id']; ?>" class="ncm-btn" target="_blank"><i class="icon-legal"></i>订单退款</a></p>
                            <?php } ?>


                            <?php if ($order_info['if_receive']) { ?>
                            <p><a href="javascript:void(0)" class="ncm-btn" nc_type="dialog" dialog_id="buyer_order_confirm_order" dialog_width="480" dialog_title="确认收货" uri="/?s=member/order/change_state&state_type=order_receive&order_sn=<?php echo $order_info['order_sn']; ?>&order_id=<?php echo $order_info['order_id']; ?>" id="order<?php echo $order_info['order_id']; ?>_action_confirm">确认收货</a></p>
                            <?php } ?>


                            <?php if ($order_info['if_evaluation']) { ?>
                            <p><a class="ncm-btn ncm-btn-acidblue" href="/?s=member/evaluate/add&order_id=<?php echo $order_info['order_id']; ?>"><i class="icon-thumbs-up-alt"></i>我要评价</a></p>
                            <?php } ?>


                            <?php if ($order_info['evaluation_state'] == 1) { echo '<span style="color:#999">已评价</span>';} ?>
                            <?php if ($order_info['if_drop']) { ?>
                            <p><a href="javascript:void(0);" onclick="ajax_get_confirm('您确定要永久删除吗?永久删除后您将无法再查看该订单，也无法进行投诉维权，请谨慎操作！', '/?s=member/order/change_state&state_type=order_drop&order_id=<?php echo $order_info['order_id']; ?>');" class="ncm-btn ncm-btn-red mt5"><i class="icon-trash"></i>永久删除</a></p>
                            <?php } ?></td>
                        <?php } ?>
                    </tr>


                    <?php if (!empty($order_info['zengpin_list']) && $i == count($order_info['goods_list'])) { ?>
                    <tr>
                        <td class="bdl"></td>
                        <td colspan="5" class="tl"><div class="ncm-goods-gift"> 赠品：
                                <ul>
                                    <?php foreach ($order_info['zengpin_list'] as $zengpin_info) { ?>
                                    <li><a title="赠品：<?php echo $zengpin_info['goods_name'];?> * <?php echo $zengpin_info['goods_num'];?>" href="<?php echo $zengpin_info['goods_url'];?>" target="_blank"><img alt="赠品：<?php echo $zengpin_info['goods_name'];?> * <?php echo $zengpin_info['goods_num'];?>" src="<?php echo $zengpin_info['image_60_url'];?>" onMouseOver="toolTip('<img src=<?php echo $zengpin_info['image_240_url'];?>>')" onMouseOut="toolTip()"/></a></li>
                                    <?php } ?>
                                </ul>
                            </div></td>
                    </tr>
                    <?php } ?>

                    <?php } ?>

                    <?php } ?>
                </tbody>
                <?php } ?>
                <?php } else { ?>
                <tbody>
                    <tr>
                        <td colspan="20" class="norecord"><div class="warning-option"><i>&nbsp;</i><span>暂无符合条件的数据记录</span></div></td>
                    </tr>
                </tbody>
                <?php } ?>
                <?php if($order_pay_list) { ?>
                <tfoot>
                    <tr>
                        <td colspan="19"><div class="pagination"> <?php echo $show_page; ?> </div></td>
                    </tr>
                </tfoot>
                <?php } ?>
            </table>
        </div>
        <script charset="utf-8" type="text/javascript" src="/old/data/resource/js/jquery-ui/i18n/zh-CN.js?{$Think.config.version_source}" ></script>
        <script charset="utf-8" type="text/javascript" src="/old/data/resource/js/sns.js?{$Think.config.version_source}" ></script>
        <script type="text/javascript">
                                        $(function(){
                                        $('#query_start_date').datepicker({dateFormat: 'yy-mm-dd'});
                                        $('#query_end_date').datepicker({dateFormat: 'yy-mm-dd'});
                                        });
        </script>

    </div>
    <div class="clear"></div>
</div>
{/block}